package tech.yiyehu.modules.bss.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import tech.yiyehu.modules.bss.entity.ImagesEntity;
import tech.yiyehu.modules.bss.service.ImagesService;
import tech.yiyehu.common.utils.PageUtils;
import tech.yiyehu.common.utils.R;



/**
 * 商品图片
 *
 * @author yiyehu
 * @email 2681844336@qq.com
 * @date 2019-06-02 23:02:00
 */
@RestController
@Api(value="图片")
@RequestMapping("bss/images")
public class ImagesController {
    @Autowired
    private ImagesService imagesService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @RequiresPermissions("bss:images:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = imagesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("bss:images:info")
    public R info(@PathVariable("id") Long id){
			ImagesEntity images = imagesService.selectById(id);

        return R.ok().put("images", images);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("bss:images:save")
    public R save(@RequestBody ImagesEntity images){
			imagesService.insert(images);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @RequiresPermissions("bss:images:update")
    public R update(@RequestBody ImagesEntity images){
			imagesService.updateById(images);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @RequiresPermissions("bss:images:delete")
    public R delete(@RequestBody Long[] ids){
			imagesService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
